<?php
/**
 * AJAX call usage: call.php?func=FUNC_NAME
 *
 * PHP versions 5
 *
 * Copyright (C)
 * This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation. Either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Without even the implied warranty
 * of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. Ff not, write to the Free Software
 * Fundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 * Copyright (C) 2006-2007
 *
 * @author Bastian Schröder <bs@chemanet.de>
 * @version 2008-04-10
 * @package railadmin
 */

session_start();

// includes
require_once( 'configs/railadmin.conf.php' );
require_once( "$cfg_pahToPHPrail/rail_connector.class.php" );
require_once( 'resources/ajaxBridge/ajaxBridge.class.php' );

// init call
$ajaxBridge = new ajaxBridge();

// set default exception handler
function exception_handler( $exception ) {
	global $ajaxBridge;
	$ajaxBridge->register_exception( $exception, 3 );
	error_log( 'Uncaught exception: ' . $exception->getMessage() );
}
set_exception_handler('exception_handler');

// connect
include('configs/connect.php');

// execute ajax_call function
include( 'callable/' . strtolower($_GET['func']) . '.func.php' );
ajax_call( $ajaxBridge );

// return JSON object
print( $ajaxBridge->json_encode() );
exit;

?>